package com.blyat.xsoft.kernel.component.extension;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Auther: syh
 * @Date: 2020/9/28
 * @Description:
 */
public class ExtensionLoaderFactory {

    private static final Map<Class, ExtensionLoader> LOADER_MAP = new ConcurrentHashMap<>();

    public static <T> ExtensionLoader<T> getExtensionLoader(Class<T> clazz) {
        ExtensionLoader<T> loader = LOADER_MAP.get(clazz);
        if (loader == null) {
            synchronized (ExtensionLoaderFactory.class) {
                if (loader == null) {
                    loader = new ExtensionLoader<>(clazz);
                    LOADER_MAP.put(clazz, loader);
                }
            }
        }
        return loader;
    }
}
